var express = require('express');
var request = require('request');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {

    var options = {
        url: 'http://jisutqybmf.market.alicloudapi.com/weather/query?city=%E5%AE%89%E9%A1%BA',
        method: 'GET',
        headers: {
            'Authorization': 'APPCODE 2c35b1494fd647398bcc1354a41e7c05'
        }
    };
    request(options, function (error, response, body) {
        if (!error && response.statusCode === 200) {
            var info = JSON.parse(body);

            //res.status(200);
            //res.type('application/json;charset=utf-8');
            res.json(info);

        }else{
            console.log('error:', error);
            console.log('statusCode:', response.statusCode);
        }
    });

});
module.exports = router;
